package com.gblfy.email.util;

import org.junit.Test;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;
import java.util.Date;

@Component
public class DateDeal {

    //日期格式化
    static SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");

    /**
     * 获取昨天日期
     *
     * @return
     */
    public static String getYesterday() {
        Date today = new Date(System.currentTimeMillis() - 1000 * 60 * 60 * 24);
        return simpleDateFormat.format(today);
    }

    /**
     * 获取今天日期
     *
     * @return
     */
    public static String getToday() {
        Date today = new Date(System.currentTimeMillis());
        return simpleDateFormat.format(today);
    }

    @Test
    public void gettoday() {
        //    2021-10-15
        System.out.println(DateDeal.getToday());
        //    2021-10-14
        System.out.println(DateDeal.getYesterday());
    }
}
